{include file="public/header"}
<body>
<style>
    .ht-main a {
        color: #555555;
        text-decoration: none;
    }
    .ht-main{
        overflow-x: hidden;
        margin-bottom: 10px;
        border-radius: 5px;
    }
    .chart {
        background-color: #ffff;
    }
    .echart{
        background-color: #FFFFFF;
        padding: 10px;
    }
    #test1{
        width: 100%;
        height: 300px;

    }
    .el-card__header{background-color: aliceblue}
    .el-col{margin-bottom: 10px;}
    
</style>
{if session('admin.auth_group_id') == 1}
<div>
    <div class="ht-main" >
        <div style="height: 300px;width: 100%;" id="echart"></div>
    </div>
    <div class="ht-main" >
        <div style="height: 300px;width: 100%;" id="echart2"></div>
    </div>
    <div class="ht-main" style="display: flex">
        <div style="height: 300px;width: 33%;" id="echart3"></div>
        <div style="height: 300px;width: 33%;" id="echart4"></div>
        <div style="height: 300px;width: 33%;" id="echart5"></div>
    </div>
</div>
{/if}
<div id="app" v-cloak style="height: auto">
    <div class="ht-main" >
        <el-descriptions title="订单数据"></el-descriptions>
        <el-table :data="tableData" border header-row-class-name="ht-table-header" ref="dataTable" row-key="id" show-summary>
            <el-table-column align="center" width="200px" prop="title" label="中心名称"></el-table-column>
            <el-table-column align="center" prop="weixiu" label="维修/加工订单数"></el-table-column>
            <el-table-column align="center" width="200px" prop="weixiu_money" label="维修/加工订单合计金额"></el-table-column>
    
            <el-table-column align="center" prop="project" label="工程订单数"></el-table-column>
            <el-table-column align="center" prop="project_money" label="工程订单金额"></el-table-column>
    
            <el-table-column align="center" prop="other" label="其他订单数"></el-table-column>
            <el-table-column align="center" prop="other_money" label="其他订单金额"></el-table-column>
    
            <el-table-column align="center" prop="share" label="市场化共享订单数"></el-table-column>
            <el-table-column align="center" prop="share_money" label="市场化共享结算金额"></el-table-column>
    
            <el-table-column align="center" prop="all_money" label="本月累计金额"></el-table-column>
            <el-table-column align="center" prop="year_money" label="本年累计金额"></el-table-column>

        </el-table>
    </div>
    
    <div class="ht-main" style="display: none">
        <el-descriptions title="矿区数据"></el-descriptions>
        <el-row :gutter="10">
            <el-col :span="8">
                <el-card shadow="hover" header="今日新增矿区" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.diggings.day}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="8">
                <el-card shadow="hover" header="矿区总数量" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.diggings.all}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="8">
                <el-card shadow="hover" header="开启矿区总数量" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.diggings.status}}
                    </div>
                </el-card>
            </el-col>
        </el-row>
    </div>
    <div class="ht-main" style="display: none">
        <el-descriptions title="厂区数据"></el-descriptions>
        <el-row :gutter="10">
            <el-col :span="8">
                <el-card shadow="hover" header="今日新增厂区" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.factory.day}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="8">
                <el-card shadow="hover" header="厂区总数量" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.factory.all}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="8">
                <el-card shadow="hover" header="开启厂区总数量" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.factory.status}}
                    </div>
                </el-card>
            </el-col>
        </el-row>
    </div>
    
    <div class="ht-main" style="display: none">
        <el-descriptions title="配件数据"></el-descriptions>
        <el-row :gutter="10">
            <el-col :span="8">
                <el-card shadow="hover" header="今日新增配件" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.parts.day}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="8">
                <el-card shadow="hover" header="配件总数量" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.parts.all}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="8">
                <el-card shadow="hover" header="开启配件总数量" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.parts.status}}
                    </div>
                </el-card>
            </el-col>
        </el-row>
    </div>
    
    <div class="ht-main" style="display: none">
        <el-descriptions title="市场化共享验收单"></el-descriptions>
        <el-row :gutter="10">
            <el-col :span="12">
                <el-card shadow="hover" header="今日创建" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.yan.day}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="12">
                <el-card shadow="hover" header="共创建" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.yan.all}}
                    </div>
                </el-card>
            </el-col>
        </el-row>
    </div>
    
    <div class="ht-main" style="display: none">
        <el-descriptions title="市场化共享结算单"></el-descriptions>
        <el-row :gutter="10">
            <el-col :span="12">
                <el-card shadow="hover" header="今日创建" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.share.day}}
                    </div>
                </el-card>
            </el-col>
            <el-col :span="12">
                <el-card shadow="hover" header="共创建" >
                    <div style="height: 50px;line-height:50px;font-size: 20px;text-align: center">
                        {{data.share.all}}
                    </div>
                </el-card>
            </el-col>
        </el-row>
    </div>
</div>

{include file="public/common"}
<script src="/static/echarts.min.js"></script>
<script>
    let vs
    var vm = new Vue({
        el: "#app",
        data: function () {
            return {
                data:{
                    share:{},
                    diggings:{},
                    factory:{},
                    parts:{},
                    yan:{}
                },
                group_id: "{:session('admin.auth_group_id')}",
                tableData:[],
            }
        },
        created(){
            vs = this
            vs.getData();
            vs.getOrderCount();
            vs.chatInit1();
            vs.chatInit2();
            vs.pieInit()
        },
        methods: {
            pieInit() {
                var chartDom3 = document.getElementById('echart3');
                var chartDom4 = document.getElementById('echart4');
                var chartDom5 = document.getElementById('echart5');
                var myChart3 = echarts.init(chartDom3);
                var myChart4 = echarts.init(chartDom4);
                var myChart5 = echarts.init(chartDom5);

                var option;
                option = {
                    tooltip: {
                        trigger: 'item'
                    },
                    series: [
                        {
                            name: '订单数据',
                            type: 'pie',
                            radius: '50%',
                            data: [
                                { value: 1048, name: 'Search Engine' },
                                { value: 735, name: 'Direct' },
                                { value: 580, name: 'Email' },
                                { value: 484, name: 'Union Ads' },
                            ],
                            emphasis: {
                                itemStyle: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }
                    ]
                };

                option && myChart4.setOption(option);
                option && myChart5.setOption(option);
                Api.request("{:url('admin/index/getPie')}").then(res=>{
                    option.series[0].data = res.data.data1
                    option && myChart3.setOption(option);
                    option.series[0].data = res.data.data2
                    option && myChart4.setOption(option);
                    option.series[0].data = res.data.data3
                    option && myChart5.setOption(option);
                })
            },
            chatInit1() {
                var chartDom = document.getElementById('echart');
                var myChart = echarts.init(chartDom);
                var option;
                option = {
                    title: {
                        text: '本月数据'
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['订单金额', '结算金额', '流转金额']
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    toolbox: {
                        feature: {
                            saveAsImage: {}
                        }
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: []
                };
                Api.request("{:url('admin/index/zhexian')}").then(res=>{
                    option.xAxis.data = res.data.day
                    option.series = res.data.series
                    option && myChart.setOption(option);
                })
            },
            chatInit2() {
                var chartDom = document.getElementById('echart2');
                var myChart = echarts.init(chartDom);
                var option;
                option = {
                    title: {
                        text: '总订单数据'
                    },
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['订单金额', '结算金额', '流转金额']
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    toolbox: {
                        feature: {
                            saveAsImage: {}
                        }
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                            name: '订单金额',
                            type: 'line',
                            stack: 'Total',
                            data: [120, 132, 101, 134, 90, 230, 210]
                        },
                        {
                            name: 'Union Ads',
                            type: 'line',
                            stack: 'Total',
                            data: [220, 182, 191, 234, 290, 330, 310]
                        },
                        {
                            name: 'Video Ads',
                            type: 'line',
                            stack: 'Total',
                            data: [150, 232, 201, 154, 190, 330, 410]
                        },
                        {
                            name: 'Direct',
                            type: 'line',
                            stack: 'Total',
                            data: [320, 332, 301, 334, 390, 330, 320]
                        },
                        {
                            name: 'Search Engine',
                            type: 'line',
                            stack: 'Total',
                            data: [820, 932, 901, 934, 1290, 1330, 1320]
                        }
                    ]
                };
                Api.request("{:url('admin/index/yearData')}").then(res=>{
                    option.xAxis.data = res.data.day
                    option.series = res.data.series
                    option && myChart.setOption(option);
                })
            },
            getData() {
                Api.request("{:url('admin/index/statistics')}").then(res=>{
                    vs.data = res.data
                })
            },
            getOrderCount() {
                Api.request("{:url('admin/index/getOrderCount')}").then(res=>{
                    vs.tableData = res.data
                })
            },
        }
    })
</script>
</body>
</html>

